The present invention relates to a method of configuring a microcontroller in a reset mode.
FIG. 1 shows a simplified diagram of a microcontroller MCU. The microcontroller, in particular, includes a central processing unit (CPU) or core which constitutes the heart of the microcontroller, and a memory MEM, such as a ROM, EPROM, EEPROM or Flash-EPROM for storing a program known as the user program. This program is loaded by the user prior to installing the microcontroller in an application.
The microcontroller MCU also includes a circuit MO serving as a main oscillator. The main oscillator MO generates a clock signal PHI1, whose frequency is on the order of about 10 MHZ, which is used to activate the microcontroller""s internal circuits. In particular, the CPU is activated when in the execution mode. The nominal frequency fCPU of this clock signal PHI1 is 8 MHZ, for example. The oscillator circuit MO can be configured by selecting a specific oscillator source for the main oscillator chosen among an external resonator (quartz) having a set frequency, an external RC circuit, an internal RC circuit, or even an external oscillator. The source of the oscillator circuit is connected to two input pins CK1 and CK2 of the microcontroller.
A clock filtering circuit CSS with a clock filter and a back-up oscillator SO is also included in the microcontroller MCU. The purpose of such a circuit is, first, to suppress pulses on the signal PHI1 occurring at a frequency exceeding a first predetermined threshold. Second, to additionally supply the CPU with a low frequency signal delivered by the back-up oscillator when the clock signal PHI1 is absent or its frequency is below a second threshold lower than the first threshold. In other words, the CSS circuit serves to continuously supply the CPU in the execution mode with a clock signal whose frequency fCPU remains within a predetermined range between the above-mentioned second and first thresholds.
The microcontroller MCU further includes a watchdog circuit WDG, and a low voltage detector LVD circuit for detecting an excessively low power supply voltage. The low voltage detector LVD receives a power supply voltage and ground through respective input terminals ALIM and GND of the microcontroller.
A reset sequence manager circuit RSM manages the microcontroller""s reset sequences. The reset sequences are initiated by reset signals which the RSM circuit receives from the WDG circuit, the LVD circuit, or external the microcontroller through an input terminal RST. One or more analog-to-digital or digital-to-analog converters (not shown) interface with the microcontroller""s analog inputs and outputs (also not shown).
The microcontroller generally contains other internal peripheral circuits. The term internal peripheral circuit is understood to mean a circuit internal to the microcontroller other than the CPU and the central memory MEM. These two internal circuits form the fundamental core vital to the operation of any microcontroller.
A reset sequence causes the microcontroller to pass from a start operating mode to a run mode. Between these two modes, i.e., during the reset sequence, the microcontroller is said to be in the reset mode. The run mode is the normal operating mode executing the program loaded into the microcontroller""s memory by the user, known as the user program.
The start operating mode depends on the manner in which the reset mode is initiated. When the reset sequence is initiated by powering up the microcontroller (power-on reset), the start mode is a power off mode. In the power off mode, all the microcontroller""s internal circuits, except for the reset manager RSM dedicated to managing the reset sequence, are disabled and non-operational. The microcontroller passes over to the run mode only when the level of a power source voltage supplied at the ALIM terminal has exceeded a predetermined threshold, known as the reset threshold. This thereby avoids the problems that could result from the microcontroller operating at too low a supply voltage. Problems include corruption or loss of data, improper sequencing of instructions due to a defective clock signal, etc.
Another manner in which the reset mode is initiated is by an external reset signal, a reset signal from the watchdog circuit WDG, or a reset signal from the low voltage detector circuit LVD. The start operating mode is the run mode.
It has been necessary to provide the user with the option to configure some of the microcontroller""s internal circuits to adapt them to application requirements. This ability to configure must not be confused with the loading of the user program into the microcontroller""s memory. The user is thus able to activate or deactivate some of the microcontroller""s functions or to customize them. This is thus a physical configuration in contrast to the software approach involved in loading the user program. Moreover, in contrast with loading of the user program, this configuration is renewed at each reset.
For example, it may be desirable to allow the user to activate or de-activate the low voltage detector LVD circuit, and/or to select a reset threshold level below which it generates a reset signal. Likewise, it may be desirable to activate or deactivate the watchdog circuit WDG.
The above is sometimes accomplished by the step of reading an option word stored in the microcontroller""s memory. This step is performed in the run mode. The values of the bits contained in this read out option word serve to set dedicated registers of the microcontroller. The option word can be read statically, i.e., continuously by specific means of the microcontroller, or read dynamically, e.g., by means of a specific instruction which the user must insert in the user program.
However, this method cannot be implemented before the microcontroller is in the run mode. All the microcontroller""s internal circuits are inhibited during the reset sequence, apart from the reset sequence manager RSM. This implies, in particular, that the configuration is not possible for the microcontroller circuits that come into play during the reset sequence itself, including the low voltage detector circuit LVD and the main oscillator MO.
It may be desirable to allow the user to configure such internal circuits of the microcontroller before entry into the run mode, and, hence, before starting execution of the user program. For instance, it may be desirable to allow the user to choose the reset threshold level of the low voltage detector circuit LVD. The user may prefer to choose this value specific to the user""s application. The higher the reset threshold, the more the operation of the microcontroller is secure. A high reset threshold guarantees that the microcontroller can only be in the run mode when the supply voltage is more than sufficient to ensure correct operation of its internal circuits. On the other hand, the higher the reset threshold, the longer the microcontroller is liable to remain in the unpowered state. Similarly, the user may wish to configure the main oscillator MO so that it operates with one oscillator source or another.
An object of the present invention is to allow the readout of at least one option word in the microcontroller when in the reset mode. This option word allows the configuration of one or more of the microcontroller""s internal circuits.
This object is achieved, in accordance with the present invention, by a method of configuring a microcontroller in a reset mode. The microcontroller comprises a central processing unit, a central memory and a main oscillator which are deactivated. The method comprises the steps of:
a) activating an auxiliary oscillator of the microcontroller;
b) generating a clock signal with the auxiliary oscillator;
c) reading an option word from a memory of the microcontroller at the rate of the clock signal; and
d) loading at least one bit of the option word into a configuration register of at least one internal circuit of the microcontroller, notably an internal peripheral circuit.
Accordingly, the option word is read out at the rate of a clock signal generated by an auxiliary oscillator dedicated to that task in the reset mode. The microcontroller""s main oscillator is activated only later, possibly after itself having been configured.
By virtue of the method according to the present invention, the microcontroller is configured only by means internal to the microcontroller. No external circuit or component needs to be provided for that purpose in the application. These advantages, as well as other characteristics and advantages shall become more apparent upon reading the description that follows.